class TestCCD extends Test
{
    public constructor(sprite:DebugDraw)
    {
        super(sprite);

        this.createScene();
    }

    private createScene():void
    {
        var bd:Box2D.Dynamics.b2BodyDef;
        var body:Box2D.Dynamics.b2Body;
        var fixtureDef:Box2D.Dynamics.b2FixtureDef = new Box2D.Dynamics.b2FixtureDef();

        fixtureDef.density = 4.0;
        fixtureDef.restitution = 1.4;

        //create basket
        {
            bd = new Box2D.Dynamics.b2BodyDef();
            bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
            bd.bullet = true;
            bd.position.Set(150 / this.m_physScale, 100 / this.m_physScale);
            body = this.m_world.CreateBody(bd);
            let sd_bottom:Box2D.Collision.Shapes.b2PolygonShape = new Box2D.Collision.Shapes.b2PolygonShape();
            sd_bottom.SetAsBox(45 / this.m_physScale, 4.5 / this.m_physScale);
            fixtureDef.shape = sd_bottom;
            body.CreateFixture(fixtureDef);

            
            let sd_left:Box2D.Collision.Shapes.b2PolygonShape = new Box2D.Collision.Shapes.b2PolygonShape();
            sd_left.SetAsOrientedBox(4.5 / this.m_physScale, 81 / this.m_physScale, new Box2D.Common.Math.b2Vec2(-43.5 / this.m_physScale, -70.5 / this.m_physScale),-0.2);
            fixtureDef.shape = sd_left;
            body.CreateFixture(fixtureDef);

            let sd_right:Box2D.Collision.Shapes.b2PolygonShape = new Box2D.Collision.Shapes.b2PolygonShape();
            sd_right.SetAsOrientedBox(4.5 / this.m_physScale, 81 / this.m_physScale, new Box2D.Common.Math.b2Vec2(43.5 / this.m_physScale, -70.5 / this.m_physScale), 0.2);
            fixtureDef.shape = sd_right;
            body.CreateFixture(fixtureDef);
        }
        
        for(var i:number = 0; i < 5; i++)
        {
            let cd:Box2D.Collision.Shapes.b2CircleShape = new Box2D.Collision.Shapes.b2CircleShape((Math.random() * 10 + 5) / this.m_physScale);
            fixtureDef.shape = cd;
            fixtureDef.friction = 0.3;
            fixtureDef.density = 1.0;
            fixtureDef.restitution = 1.1;
            bd = new Box2D.Dynamics.b2BodyDef();
            bd.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
            bd.bullet = true;
            bd.position.Set((Math.random() * 300 + 250) / this.m_physScale, (Math.random() * 300 + 20) / this.m_physScale);
            body = this.m_world.CreateBody(bd);
            body.CreateFixture(fixtureDef);
        }

    }
}